Replication package — figures (Stata, portable paths)
==================================================

This package generates the figures used in the paper. The do-files are written to be portable:
all paths are defined relative to the project root (the current Stata working directory).

--------------------------------------------------
1) Expected folder structure
--------------------------------------------------

Project root = the folder that contains:

project_root/
  00_setup.do
  master.do
  data/
    Workable_dataset.dta
  do/
    do_Fig2_portable.do
    do_Fig3_portable.do
    do_Fig4_portable.do
  output/              (created automatically if missing)
    figures/           (created automatically if missing)

Notes
- Folder names are case-sensitive on some systems. Keep them exactly as shown.
- The scripts use forward slashes in paths; this works on Windows/macOS/Linux.

--------------------------------------------------
2) Quick start
--------------------------------------------------

Open Stata and run:

    cd "path/to/project_root"
    do "master.do"

Figures will be written to:

    output/figures/

--------------------------------------------------
3) Diagnostics (recommended if an error occurs)
--------------------------------------------------

Before running `master.do`, confirm that Stata is in the correct folder:

    display "PWD: `c(pwd)'"
    confirm file "00_setup.do"
    confirm dir  "data"
    confirm dir  "do"
    dir "do"
    dir "data"

If any `confirm` command fails, the working directory or folder layout is not as expected.

--------------------------------------------------
4) Common issues and fixes
--------------------------------------------------

Error r(601): file ... not found
This usually means Stata is not started in the project root (or `cd` was not set there),
so relative paths like `do "do/do_Fig2_portable.do"` cannot be resolved.

Fix:
1) Set the working directory explicitly, then re-run:

    cd "path/to/project_root"
    do "master.do"

Running a do-file by absolute path
If `master.do` is run via an absolute path, Stata may not change the working directory automatically.
Set the working directory via `cd` first.

Files stored in a different subfolder (e.g., “Do files/Figures”)
If the package is reorganized, either:
- restore the expected `data/` and `do/` folders under the project root, or
- update the `do ".../..."` lines in `master.do` accordingly.

--------------------------------------------------
5) What `00_setup.do` does
--------------------------------------------------

`00_setup.do` defines:
- ROOT = current working directory (`c(pwd)`)
- DATA = "$ROOT/data"
- OUT  = "$ROOT/output/figures"

It also creates the output folders if they are missing.

--------------------------------------------------
Reporting issues
--------------------------------------------------

If replication fails, include the Stata log and the output of:
    display c(pwd)
    dir
    dir data
    dir do
